package com.konke.smartpad_huahao.domain;

/**
 * Created by Administrator on 2017/10/19.
 */

public class AcUtil {


    /**
     * mode  //当前模式  0：制冷模式 1：制热模式  2：通风模式 3：除湿模式
     * wind  //当前风速  0：低速  1：中速  2：高速
     *
     * @param nowTemp
     * @param mode
     * @param wind
     * @return
     */
    public static int findArg(int nowTemp, int mode, int wind) {
        int arg = -1;
        if (mode == 0 && wind == 0) {
            switch (nowTemp) {
                case 20:
                    arg = 2;
                    break;
                case 21:
                    arg = 3;
                    break;
                case 22:
                    arg = 4;
                    break;
                case 23:
                    arg = 5;
                    break;
                case 24:
                    arg = 6;
                    break;
                case 25:
                    arg = 7;
                    break;
                case 26:
                    arg = 8;
                    break;
                case 27:
                    arg = 9;
                    break;
                case 28:
                    arg = 10;
                    break;
                case 29:
                    arg = 11;
                    break;
                case 30:
                    arg = 12;
                    break;
            }
        } else if (mode == 0 && wind == 1) {
            switch (nowTemp) {
                case 20:
                    arg = 13;
                    break;
                case 21:
                    arg = 14;
                    break;
                case 22:
                    arg = 15;
                    break;
                case 23:
                    arg = 16;
                    break;
                case 24:
                    arg = 17;
                    break;
                case 25:
                    arg = 18;
                    break;
                case 26:
                    arg = 19;
                    break;
                case 27:
                    arg = 20;
                    break;
                case 28:
                    arg = 21;
                    break;
                case 29:
                    arg = 22;
                    break;
                case 30:
                    arg = 23;
                    break;
            }
        } else if (mode == 0 && wind == 2) {
            switch (nowTemp) {
                case 20:
                    arg = 24;
                    break;
                case 21:
                    arg = 25;
                    break;
                case 22:
                    arg = 26;
                    break;
                case 23:
                    arg = 27;
                    break;
                case 24:
                    arg = 28;
                    break;
                case 25:
                    arg = 29;
                    break;
                case 26:
                    arg = 30;
                    break;
                case 27:
                    arg = 31;
                    break;
                case 28:
                    arg = 32;
                    break;
                case 29:
                    arg = 33;
                    break;
                case 30:
                    arg = 34;
                    break;
            }
        } else if (mode == 1 && wind == 0) {
            switch (nowTemp) {
                case 20:
                    arg = 35;
                    break;
                case 21:
                    arg = 36;
                    break;
                case 22:
                    arg = 37;
                    break;
                case 23:
                    arg = 38;
                    break;
                case 24:
                    arg = 39;
                    break;
                case 25:
                    arg = 40;
                    break;
                case 26:
                    arg = 41;
                    break;
                case 27:
                    arg = 42;
                    break;
                case 28:
                    arg = 43;
                    break;
                case 29:
                    arg = 44;
                    break;
                case 30:
                    arg = 45;
                    break;
            }
        } else if (mode == 1 && wind == 1) {
            switch (nowTemp) {
                case 20:
                    arg = 46;
                    break;
                case 21:
                    arg = 47;
                    break;
                case 22:
                    arg = 48;
                    break;
                case 23:
                    arg = 49;
                    break;
                case 24:
                    arg = 50;
                    break;
                case 25:
                    arg = 51;
                    break;
                case 26:
                    arg = 52;
                    break;
                case 27:
                    arg = 53;
                    break;
                case 28:
                    arg = 54;
                    break;
                case 29:
                    arg = 55;
                    break;
                case 30:
                    arg = 56;
                    break;
            }
        } else if (mode == 1 && wind == 2) {
            switch (nowTemp) {
                case 20:
                    arg = 57;
                    break;
                case 21:
                    arg = 58;
                    break;
                case 22:
                    arg = 59;
                    break;
                case 23:
                    arg = 60;
                    break;
                case 24:
                    arg = 61;
                    break;
                case 25:
                    arg = 62;
                    break;
                case 26:
                    arg = 63;
                    break;
                case 27:
                    arg = 64;
                    break;
                case 28:
                    arg = 65;
                    break;
                case 29:
                    arg = 66;
                    break;
                case 30:
                    arg = 67;
                    break;
            }
        } else if (mode == 2 && wind == 0) {
            arg = 68;
        } else if (mode == 2 && wind == 1) {
            arg = 79;
        } else if (mode == 2 && wind == 2) {
            arg = 90;
        } else if (mode == 3 && wind == 0) {
            arg = 101;
        } else if (mode == 3 && wind == 1) {
            arg = 112;
        } else if (mode == 3 && wind == 2) {
            arg = 123;
        }
        return arg;
    }


    /**
     * mode  //当前模式  0：制冷模式 1：制热模式  2：通风模式 3：除湿模式
     * wind  //当前风速  0：低速  1：中速  2：高速
     */
    public static int[] getModeSpeedTemp(int codeId) {

        if (codeId == -1 || codeId == 0) {
            return new int[]{0, 0, 20};
        }
        if (codeId == 1) {
            return new int[]{0, 0, 20};
        }

        int nowMode = -1, nowWind = -1, temp = -1;

        if (codeId > 1 && codeId <= 12) {
            nowMode = 0;
            nowWind = 0;
        } else if (codeId > 12 && codeId <= 23) {
            nowMode = 0;
            nowWind = 1;
        } else if (codeId > 23 && codeId <= 34) {
            nowMode = 0;
            nowWind = 2;
        } else if (codeId > 34 && codeId <= 45) {
            nowMode = 1;
            nowWind = 0;
        } else if (codeId > 45 && codeId <= 56) {
            nowMode = 1;
            nowWind = 1;
        } else if (codeId > 56 && codeId <= 67) {
            nowMode = 1;
            nowWind = 2;
        } else if (codeId > 67 && codeId <= 78) {
            nowMode = 2;
            nowWind = 0;
        } else if (codeId > 78 && codeId <= 89) {
            nowMode = 2;
            nowWind = 1;
        } else if (codeId > 89 && codeId <= 100) {
            nowMode = 2;
            nowWind = 2;
        } else if (codeId > 100 && codeId <= 111) {
            nowMode = 3;
            nowWind = 0;
        } else if (codeId > 111 && codeId <= 122) {
            nowMode = 3;
            nowWind = 1;
        } else if (codeId > 122 && codeId <= 133) {
            nowMode = 3;
            nowWind = 2;
        }

        if (codeId % 11 == 0) {
            temp = 29;
        } else if (codeId % 11 == 1) {
            temp = 30;
        } else {
            temp = codeId % 11 + 18;
        }

        if (nowMode != -1  && temp != -1) {
            return new int[]{nowMode, nowWind, temp};
        } else {
            return null;
        }
    }

    
}
